package com.dhb.base.rabbitmq;


import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
@RabbitListener(queues = "orderCustomsResult")
public class ClmNeedPaperMqReciever {

    @RabbitHandler
    public void process(String orderCustomsResult,com.rabbitmq.client.Channel channel,@Header(AmqpHeaders.DELIVERY_TAG) long tag) {
        System.out.println("Receiver  : " + orderCustomsResult);
        try {
            channel.basicAck(tag, false);

//            //消息的标识，false只确认当前一个消息收到，true确认所有consumer获得的消息
//            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
//            //ack返回false，并重新回到队列，api里面解释得很清楚
//            channel.basicNack(message.getMessageProperties().getDeliveryTag(), false, true);
//            //拒绝消息
//            channel.basicReject(message.getMessageProperties().getDeliveryTag(), true);
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
